﻿using System;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.QualityTools.Testing.Fakes;
using Xrm.Solutions.FrameworkSample.Common;

namespace Xrm.Solutions.FrameworkSample.UnitTests
{
    [TestClass]
    public class TestCreditLimitShim
    {
        [TestMethod]
        public void TestCreditLimitUsingShim()
        {
            using (ShimsContext.Create())
            {
                Xrm.Solutions.FrameworkSample.Common.Fakes.ShimIdentityCheckService.AllInstances.RunCheckStringStringDateTimeString =
                    (service, firstname, lastname, dob, address) =>
                    {
                        if (firstname == "Wael")
                            return 99;
                        else
                            return 60;
                    };

                CreditLimitServiceHD creditLimitService = new CreditLimitServiceHD();

                int creditLimit = creditLimitService.IncreaseLimit("Any",
                                            "Hamze",
                                            new DateTime(1990, 01, 01),
                                            "10 South Colonnade",
                                            500,
                                            600);

                Assert.AreEqual(creditLimit, 500);
            }
        }
    }
}
